// const country = require('./lib/country'); //国家
const name = require('./lib/name'); //姓名
// const sex = require('./lib/sex'); //性别
// const company = require('./lib/company'); //公司
const age = require('./lib/age'); //年龄
const avatar = require('./lib/avatar'); //头像
const utils = require('./lib/utils');

const fs = require('fs-extra')

const json = fs.readJsonSync('./data/emails.json');
let emails = {};
if ( JSON.stringify(json) === "{}" ) {
    emails.data = [];
} else {
    emails = json;
}

const generate = function() {
    let country = "China";
    let sex = "male";
    let personalNameObj = name.get(country);
    let personalName = personalNameObj.firstName + personalNameObj.lastName;
    let personalNickname = "";
    
    if ( country === "China" ) {
        personalNickname = utils.topy(personalName);
    } else {
        personalNickname = personalName;
    }
    
    let personal = {
        name: personalName,
        nickname: personalNickname,
        avatar: avatar.get("male"),
        age: age.get(),
        sex: sex,
        github: {
            email: personalNickname + "@packhub.net",
            passowrd: personalNickname + "520"
        }
    }
    emails.data.push(personal);
}

Array.from({length: 200}).forEach((i,index) => {
    generate();
});

fs.writeFileSync('./data/emails.json', JSON.stringify(emails, null, 4));